/*******************************************************************************
 * * Copyright 2011 Impetus Infotech.
 *  *
 *  * Licensed under the Apache License, Version 2.0 (the "License");
 *  * you may not use this file except in compliance with the License.
 *  * You may obtain a copy of the License at
 *  *
 *  *      http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  * Unless required by applicable law or agreed to in writing, software
 *  * distributed under the License is distributed on an "AS IS" BASIS,
 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  * See the License for the specific language governing permissions and
 *  * limitations under the License.
 ******************************************************************************/
package com.scalyze.apps.socialanyltics.collector;

import java.util.Iterator;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import com.scalyze.apps.socialanyltics.trends.fashion.WomenFashion;

/**
 * @author vivek.mishra
 *
 */
public class ThreadPoolExec
{

    /**
     * @param args
     */
    public static void main(String[] args)
    {
//        ThreadPoolExecutor pool = new ThreadPoolExecutor(4,4)
        int poolSize = 2;
        
        int maxPoolSize = 2;
     
        long keepAliveTime = 10;
     
        ThreadPoolExecutor threadPool = null;
     
        final ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(
                3);
        
        queue.add(new ThreadExecutor(WomenFashion.getClothingTrend()));
        queue.add(new ThreadExecutor(WomenFashion.getBags()));
        queue.add(new ThreadExecutor(WomenFashion.getShoes()));
        threadPool = new ThreadPoolExecutor(poolSize, maxPoolSize,
                keepAliveTime, TimeUnit.SECONDS, queue);
//        while(queue.i)
        Iterator<Runnable> iter = queue.iterator();
        while(iter.hasNext())
        {
            threadPool.execute(iter.next());
        }

    }

}
